package top.resty.erp.dao;

import org.apache.ibatis.annotations.*;
import top.resty.erp.domain.Brand;

import java.util.List;

/**
 * <pre>
 *
 * </pre>
 *
 * @author : resty
 * @date : 2021年03月21 16:49
 */
@Mapper
public interface IBrand {
	
	@Insert("insert into tb_brand values(null,#{name})")
	public int saveBrand(String name);
	
	@Select({
			"<script>" +
			"select * from tb_brand" +
					"<if test='search != null and search != \"\"'>" +
					"where name like '%${search}%'" +
					"</if>" +
			"</script>"
	})
	public List<Brand> getBrands(@Param("search") String searchName);
	
	
	/**  ${arg0} = #{arg1}   解析时$不包含'' 而#包含''  代表是数值  **/
	@Update("update tb_brand set ${arg0} = #{arg1} where id = #{arg2}")
	public int updateBrand( String keyStr,String valueStr,Integer id);
	
	@Delete("delete from tb_brand where id = #{id}")
	int delete(int id);
	
	
	@Select("select * from tb_brand")
	public List<Brand> getAllBrands();
	
	
	
}
